package com.shiguo365.market.presenter.implement;

import android.app.Activity;
import android.support.annotation.NonNull;
import android.util.Log;

import com.alibaba.fastjson.JSONObject;
import com.shiguo365.market.display.view.IUserCenterView;
import com.shiguo365.market.presenter.contract.IUserCenterPresenter;

import biz.yfsoft.app.aengine.api.AEClient;
import biz.yfsoft.app.aengine.api.AEParam;
import biz.yfsoft.app.aengine.api.BaseAECallback;

/**
 * Created by CoderA on 2016/7/9.
 */
public class UserCenterPresenter implements IUserCenterPresenter {

    private static final String TAG = "UserCenterPresenter";
    private final Activity mActivity;
    private final IUserCenterView mView;

    public UserCenterPresenter(@NonNull Activity activity, @NonNull IUserCenterView view) {
        this.mActivity = activity;
        this.mView = view;
    }


    @Override
    public void getUserInfoById(Integer uid) {
        AEClient _client = new AEClient("shiguo.user.getUserInfoById");
        _client.call(new AEParam().set("uid",uid),new BaseAECallback() {

            @Override
            public void onSuccess(JSONObject a) {
                mView.onGetUserInfoOk(a);
            }

            @Override
            public void onError( String errno, String message) {
                Log.e(TAG,"onFailure ......." + errno + ";message:" + message);
            }

            @Override
            public void onFinally() {
                mView.onGetUserInfoFinished();
            }
        });
    }
}
